package com.wasai.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

@SuppressWarnings("serial")
@MappedSuperclass
public abstract class BaseDomain implements Serializable {
	private Integer id;

	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}
		if (!(obj instanceof BaseDomain)) {
			return false;
		}

		final BaseDomain target = (BaseDomain) obj;
		return this.hashCode() == target.hashCode();
	}

	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	@Override
	public int hashCode() {
		if (this.getId() != null) {
			return this.getId().hashCode();
		} else {
			return super.hashCode();
		}
	}

	public void setId(final Integer id) {
		this.id = id;
	}
}
